//
//  EntranceGuardViewController.m
//  CRSCMOA
//
//  Created by goldnut on 16/8/31.
//  Copyright © 2016年 王文晓. All rights reserved.
//

#import "EntranceGuardViewController.h"
#import "CreatQRCodeAndBarCodeFromLeon.h"

@interface EntranceGuardViewController ()

- (IBAction)applyBtn:(UIButton *)sender;

@property (weak, nonatomic) IBOutlet UIImageView *codeImage;






@end

@implementation EntranceGuardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpNavgationBar];
    
}

#pragma mark - 设置导航条
- (void)setUpNavgationBar
{
    self.title = @"门禁";
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"＜" style:UIBarButtonItemStylePlain target:self action:@selector(leftBtnClick)];
    
}

#pragma mark ---按钮回调--

- (void)leftBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (IBAction)applyBtn:(UIButton *)sender {
    //POST请求
    NSDictionary *mdic = [NSDictionary dictionaryWithObjectsAndKeys:UID,@"uid",nil];
    [JNTDataRequestTools postFetchDataWithUrlString:EntranceGuar_URL paramenters:mdic success:^(id data) {
        // 请求成功，解析数据
        NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSString *imageStr = resultDic[@"encryptCode"];
        self.codeImage.image = [CreatQRCodeAndBarCodeFromLeon qrImageWithString:imageStr size:CGSizeMake(200, 200) color:[UIColor blackColor] backGroundColor:[UIColor whiteColor]];
        
    } fail:^{
        
        NSLog(@"话题列表请求失败");
    } view:self.view];
 
}




@end
